#include<iostream>
using namespace std;
#include<unistd.h>
#include<pthread.h>
void* newthread(void * s)
{
    int n = 5;
    while(n--)
    {
        cout<<static_cast<char*>(s)<<endl;
        sleep(1);
    }
    return (void*)666;
}
string PrintHex(pthread_t& id)
{
    char buf[64];
    snprintf(buf, sizeof(buf), "%lx", id);
    return buf;
}
int main()
{
    pthread_t id;
    int n = pthread_create(&id, nullptr, newthread, (void *)"syx 666");
    if(n!=0)
    {
        cerr << "create thread error" << endl;
        return 1;
    }
    cout << PrintHex(id) << endl;
    void *code = nullptr;
    n = pthread_join(id, &code);
    if(n==0)
    {
        cout << "wait success!ret:" <<(uint64_t)code<< endl;
    }
    return 0;
}